home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d1 / fsize.arc / FSIZE.C next >
Encoding:
C/C++ Source or Header  |  1986-01-11  |  1.1 KB  |  49 lines

  1. #include "fcntl.h"
  2. #include "sys\types.h"
  3. #include "sys\stat.h"
  4. #include "process.h"
  5. #include "string.h"
  6. #include "direct.h"
  7. #include "io.h"
  8. #include "stdio.h"
  9. #include "stdlib.h"
  10.  
  11. #define FILE_ERR -1
  12.  
  13. void main(argc,argv)
  14.        int argc;
  15.        char *argv[];
  16. {
  17.        int i,handle,result,fcount;
  18.        long cumm_size;
  19.        char path[65];
  20.        struct stat stat_buf;
  21.  
  22.        cumm_size=0L;
  23.        fcount=0;
  24.  
  25.        printf("\nFSIZE.EXE by Bryan D. Kaiser");
  26.        if(argc==1){
  27.           printf("\nNo files specified\nUsage:FSIZE [FILE SPEC]");
  28.           exit(0);
  29.        }
  30.  
  31.        for(i=1;i < argc;i++){
  32.           if((result = stat(argv[i],&stat_buf)) != 0){
  33.              strcpy(path,"\n");
  34.              strcat(path,argv[i]);
  35.              perror(path);
  36.              exit(0);
  37.           }
  38.           if(stat_buf.st_mode & S_IFDIR)
  39.              continue;
  40.  
  41.           cumm_size += stat_buf.st_size;
  42.           ++fcount;
  43.           printf("\n%-*s%7ld",strlen(argv[1])+11,strlwr(argv[i]),stat_buf.st_size);
  44.        }
  45.  
  46.        printf("\n\n%d files occupy %ld bytes\n",fcount,cumm_size);
  47.  
  48. }
  49.